package com.weihj;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.weihj.entity.Iuser;
import com.weihj.mapper.IuserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by weihuajiang on 2017/6/23.
 */
@RestController
public class TestController {

    @Autowired
    private IuserMapper userMapper;

    @RequestMapping("/test")
    PageInfo<Iuser> test() {
//        userMapper.listUsers();
        PageHelper.startPage(2, 2);
        List<Iuser> users = userMapper.selectAll();
        return new PageInfo<Iuser>(users);
    }

    @RequestMapping("/saveUser")
    boolean saveUser(@RequestBody Iuser user) {
        try {
//            userMapper.insert(user);

            userMapper.insertSelective(user);
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
}
